<?
  /* File:    lib/database.db_listfields.tx: externalized code for getting
   *          a field list from a table
   * Type:    CMS function library
   * Author:  udo.schroeter@gmail.com
   * License: LGPL / commercially licensed 
   * Todo:    /
   * Changes: -
   */

  $fieldDesc = array();
  
  $result = mysql_query("SELECT * FROM ".$tablename." LIMIT 1");
  $fields = @mysql_num_fields($result);
  $table = @mysql_field_table($result, 0);
  for ($i=0; $i < $fields; $i++)
  {
    $fieldName = mysql_field_name($result, $i);
    @$fullInfo = array(
            'type' => mysql_field_type($result, $i),
            'name' => $fieldName,
            'length' => mysql_field_len($result, $i),
            'flags' => explode(' ', mysql_field_flags($result, $i)),
            );
      
     $fieldDesc[$fieldName] = $fullInfo; 
  }
  @mysql_free_result($result);
?>
